package group6renderer;

import group6renderer.renderernode.*;


/**
*
* @author Yiannis
*/

public class Renderer implements Visitor{

	//private TreeNode node;
	private Display display;

	Renderer(TreeNode node)
	{
		//this.node=node;
		display=new Display();
		render(node);
	}

	public void render(TreeNode node)
	{
		int i=0;
		
		node.accept(this);
		while (!node.isLeaf() && i<node.getChildrenNum() )
		{	
				render(node.getChild(i));
				i++;
		}	
		if(node instanceof FormatNode)
		{
			node.accept(this);
		}  
		
		
	}
	
	public void visit(FormatNode node) {
		node.drawNode(display); 
	}
	
	
	public void visit(TitleNode node) {
		node.drawNode(display);
	}
	
	
	public void visit(TableNode node) {
		node.drawNode(display);
		//for(int i=0;i< node.getChildrenNum();i++) {
		//	visit(node.getChild(i));
		//}
	//	node.addTable();
	}
	
	public void visit(LeafNode node) {
		node.drawNode(display);
	}

	public void visit(BranchNode node) {
		node.drawNode(display);
		//for (child : node.children) {
			//visit(child);
		//}
	}


	public void visit(ListNode node) {
		node.drawNode(display);
	}


	
}
